<?php

namespace App\Http\Controllers\Admin;

use App\Library\Upload;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use League\Flysystem\Config;
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;

class UploadController extends Controller
{
    public function addImg(Request $request){
        if (!$request->hasFile('file')) {
           return $this->ajax(false, '请选择文件');
        }
        $file = $request->file('file');
        if (!$file->isValid()){
            return  $this->ajax(false, '文件上传出错');
        }
        $upload=new Upload();
        $ret=$upload->img($file);
        return response()->json($ret);

    }
    public function addFile(Request $request){
        $str='{
                "imageUrl": "/admin/upload/addimg",
                "imagePath": "/img/",
                "imageFieldName": "upfile",
                "imageMaxSize": 2048,
                "imageAllowFiles": [
                    ".png",
                    ".jpg",
                    ".jpeg",
                    ".gif",
                    ".bmp"
                ]
            }';
        echo $str;
    }
}
